<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<%@include file="../common/header.jsp"%>
<title>我的收藏</title>
</head>
<script>

function deleteCollect(i)
{
	
	$.messager.confirm("消息提醒", "你确定要删除这个收藏吗",function (data) {
        if (data) {
        	
        	$.ajax({
        		type: "post",
        		url: "/TeaShop/home/account/delete_collect",
        		data: {id:i}, 
        		dataType: "json", //返回数据类型
        		success: function(result){
        			if(result.type == 'success'){
        				$.messager.alert("消息提醒", result.msg, "info", function () {window.location.href = "/TeaShop/home/account/collect?page=1&rows=4&accountId=${account.id}";});
        			}
        			else{
        				$.messager.alert("消息提醒", result.msg, "warning");
        				
        			}
        			
        		}
        		
        	});
        	
        }
        else {
        	
        	return;
        	
        }
    });
	
	
}

</script>
<body>
<%@include file="../common/common_top.jsp"%>
<!--导航栏样式-->
<div id="Menu" class="clearfix">
<div class="Menu_style">
  <div id="allSortOuterbox" class="display">
    <div class="Category"><a href="/TeaShop/home/product/list" class="Menu_img"><em></em></a></div>
    <div class="hd_allsort_out_box_new">
	 <!--左侧栏目开始-->
	 <div class="Menu_list">	
	    <div class="menu_title">茶叶品种</div>
	    	<c:forEach items="${teaCategoryList}" var="teaCategory">
				<a class="nav_on" id="mynav"  href="${teaCategory.href}">${teaCategory.name}</a>
			</c:forEach>
	</div>	
    <div class="Menu_list">	
	    <div class="menu_title">茶叶价格</div>
        <a href="/TeaShop/home/product/list?price=1&flag2=1">100以下</a><a href="/TeaShop/home/product/list?price=2&flag2=1">100-200</a>
        <a href="/TeaShop/home/product/list?price=3&flag2=1">200-400</a><a href="/TeaShop/home/product/list?price=4&flag2=1">400-600</a>
        <a href="/TeaShop/home/product/list?price=5&flag2=1">600-900</a><a href="/TeaShop/home/product/list?price=6&flag2=1">1000以上</a>
	</div>	
     <div class="Menu_list">	
	    <div class="menu_title">推荐茶叶</div>
        <ul class="recommend">
       		<c:set var="count" value="0"></c:set>
            <c:forEach items="${teaListByActionId}" var="tea">
             		<!-- 只允许显示2个 -->
             		<c:if test="${count < 2}">
        			 	<li><a href="${tea.href}" title="${tea.name}">${tea.name}</a></li>
              		  	<c:set var="count" value="${count+1}"></c:set>
       			</c:if>
       		</c:forEach>
        </ul>
	</div>	
	</div>		
	</div>
    <div class="Navigation" id="Navigation">
		 <ul class="Navigation_name">
			<li><a class="nav_on" id="mynav"  href="/TeaShop/home/system/index"><span>首页</span></a></li>
			<c:forEach items="${teaCategoryList}" var="teaCategory">
				<li><a class="nav_on" id="mynav"  href="${teaCategory.href}"><span>${teaCategory.name}</span></a></li>
			</c:forEach>
		 </ul>			 
	</div>
    <!--购物车-->	
    
     <div class="hd_Shopping_list" id="Shopping_list">
   <div class="s_cart"><em></em><a href="#">我的购物车</a> <i class="ci-right">&gt;</i><i class="ci-count" id="shopping-amount">${cartTotal}</i></div>
   <div class="dorpdown-layer">
       <div class="spacer"></div>
	 <!--<div class="prompt"></div><div class="nogoods"><b></b>购物车中还没有商品，赶紧选购吧！</div>-->
	 <ul class="p_s_list">
	 
	 	 <c:set var="totalPrice" value="0"></c:set>
 		 <c:forEach items="${cartList}" var="cart" varStatus="vs">
			  <li>
			    <div class="img"><img src="${cart.tea.photo}" style="width:40px;height:40px;"></div>
			    <div class="content">
			      <p><a href="${cart.tea.href}">${cart.tea.name}</a></p><p>${cart.tea.info}</p>
			    </div>
				<div class="Operations">
				<p class="Price">￥${cart.tea.new_price}</p>
				<p>数量：${cart.num}</p></div>
			  </li>
			   <c:set var="totalPrice" value="${totalPrice+cart.tea.new_price*cart.num}"></c:set>
		 </c:forEach>
		  
	</ul>		
	 <div class="Shopping_style">
	 <div class="p-total">共<b>${cartTotal}</b>件商品　共计<strong>￥ ${totalPrice}</strong></div>
	  <a href="/TeaShop/home/shopping/cart" title="去购物车结算" id="btn-payforgoods" class="Shopping">去购物车结算</a>
	 </div>	 
   </div>	
  </div>
</div>
</div>
<!--用户中心(收藏)-->
<div class="user_style clearfix" id="user">
<div class="user_title"><em></em>用户中心</div>
  <div class="clearfix user" >
  <!--左侧菜单栏样式-->
   <div class="user_left">
      <div class="user_info">
       <div class="Head_portrait"><img src="${account.photo}"  width="80px" height="80px"/><!--头像区域--></div>
       <div class="user_name">${account.username}<a href="/TeaShop/home/account/info">[个人资料]</a></div>
      </div>
      <ul class="Section">
       <li><a href="/TeaShop/home/account/info"><em></em><span>个人信息</span></a></li>
       <li><a href="/TeaShop/home/account/password"><em></em><span>修改密码</span></a></li>
       <li><a href="/TeaShop/home/account/order?page=1&rows=7"><em></em><span>我的订单</span></a></li>
       <li><a href="/TeaShop/home/account/comment?page=1&rows=4"><em></em><span>我的评论</span></a></li>
       <li><a href="/TeaShop/home/account/collect?page=1&rows=4&accountId=${account.id}"><em></em><span>我的收藏</span></a></li>
       <li><a href="/TeaShop/home/account/address"><em></em><span>收货地址管理</span></a></li>
      </ul>
    </div>
     <!--右侧内容样式-->
   <div class=" right_style r_user_style user_right">
    <div class="user_Borders clearfix">
    <div class="title_name">
        <span class="name">用户收藏</span>
       </div>
   <!--收藏样式-->
    <div class="Collect">
      <ul class="Collect_list">
      	<c:forEach items="${collectList}" var="collect">
	       <li>
		       <div class="Collect_pro_name">
		         <a href="javascript:void(0)" onclick="deleteCollect(${collect.id});" class="delete_Collect"></a>
		        <p class="img center"><a href="/TeaShop/home/product/detail?productId=${collect.productId}"><img src="${collect.photo}" /></a></p>
		        <p><a href="/TeaShop/home/product/detail?productId=${collect.productId}">${collect.name}</a></p>
		        
		        <p class="Collect_price">￥${collect.price}</p>
		        </div>
	       </li>
	     </c:forEach>
        
        
      </ul>
      <!--分页-->
      <div class="Paging_style">
       
	      <!-- 上一页 -->
	   	  <c:if test="${currentPage != 1}">
	     	 <a href="/TeaShop/home/account/collect?page=${currentPage-1}&rows=4&accountId=${account.id}">&lt;上一页</a>
	      </c:if>
	      <c:if test="${currentPage == 1}">
	     	 <a href="javascript:void(0);">没有上一页了</a>
	      </c:if>
	      
          <!-- 中间部分 -->
	     <c:forEach begin="1" end="${totalPage}" step="1" var="item">
	     	
			<c:if test="${item == currentPage-2}">
			 		<a href="/TeaShop/home/account/collect?page=${item}&rows=4&accountId=${account.id}">${item}</a>
			</c:if>
			<c:if test="${item == currentPage-1}">
			 		<a href="/TeaShop/home/account/collect?page=${item}&rows=4&accountId=${account.id}">${item}</a>
			</c:if>
			<c:if test="${item == currentPage}">
			 	<a href="/TeaShop/home/account/collect?page=${item}&rows=4&accountId=${account.id}" class="on">${item}</a>
			</c:if>
			<c:if test="${item == currentPage+1}">
			 		<a href="/TeaShop/home/account/collect?page=${item}&rows=4&accountId=${account.id}">${item}</a>
			</c:if>
			<c:if test="${item == currentPage+2}">
			 		<a href="/TeaShop/home/account/collect?page=${item}&rows=4&accountId=${account.id}">${item}</a>
			</c:if>
		 </c:forEach>
	 
	 	  <!-- 下一页 -->
		 <c:if test="${currentPage != totalPage}">
		 	<a href="/TeaShop/home/account/collect?page=${currentPage+1}&rows=4&accountId=${account.id}">下一页&gt;</a>
		 </c:if>
		 <c:if test="${currentPage == totalPage}">
		 	<a href="javascript:void(0);">没有下一页了</a>
		 </c:if>
	 
	 	 <span class="p-skip">共<b>${totalPage}</b>页&nbsp;&nbsp;</span>	
	 
      </div>
    </div>
    </div>
   </div>
  </div>
 </div>
 
<%@include file="../common/footer.jsp"%>
</body>
</html>